package com.ndp.fb.rdb.model;

import com.ndp.fb.rdb.annotation.Column;
import com.ndp.fb.rdb.annotation.Id;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;

@Setter
@Getter
@NoArgsConstructor
public class AdCreative implements Serializable {
    /**
     * 描述   (@author: yanghao)
     */
    private static final long serialVersionUID = 3125825295673808720L;
    @Id
    private Long id;
    //ad_creative_id
    private Long adCreativeId;
    //fb_account_id
    private Long fbAccountId;
    //product_conf_id
    private Long productConfId;
    //fb_connection_object_id
    private Long fbConnectionObjectId;
    //publish_batch_id
    private Long publishBatchId;
    //run_status
    private String runStatus;
    //object_store_url
    private String objectStoreUrl;
    //object_story_spec
    private String objectStorySpec;
    //object_story_id
    private String objectStoryId;
    @Column("imageMd5")
    private String imageMd5;
    @Column("videoMd5")
    private String videoMd5;
    //image_hash
    private String image_hash;
    //image_url
    private String image_url;
    //object_type
    private String object_type;
    //thumbnail_url
    private String thumbnail_url;

    private Long ecTemplateMaterielId;


    public void setObjectStorySpec(String objectStorySpec){
        this.objectStorySpec=objectStorySpec.replaceAll("[^\\u0000-\\uFFFF]", "^emoji^");
    }

    @Override
    public int hashCode() {
        return adCreativeId.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (obj instanceof AdCreative) {
            AdCreative other = (AdCreative) obj;
            if (adCreativeId == null) {
                if (other.getAdCreativeId() != null) {
                    return false;
                }
            } else if (!adCreativeId.equals(other.getAdCreativeId())) {
                return false;
            } else {
                if (objectStorySpec != null) {
                    if (objectStorySpec.equals(other.getObjectStorySpec())) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

}
